package com.itheima.HomeWork_day07;

import java.time.LocalDate;
import java.time.Period;

/*
 *  计算两个时间的间隔
 */
public class PeriodTest06 {
    public static void main(String[] args) {

        LocalDate localDate1 = LocalDate.of(2020, 12, 05);
        LocalDate localDate2 = LocalDate.of(2022, 8, 15);

        //计算时间间隔
        Period period = Period.between(localDate1, localDate2);
        System.out.println(period);

        //获取年数
        System.out.println(period.getYears());

        //获取期间的月数
        System.out.println(period.getMonths());

        //获取期间的天数
        System.out.println(period.getDays());

        //获取此期间的总月数
        System.out.println(period.toTotalMonths());

    }
}
